package logic

import (
	"baidu/baidurpc/baidurpc"
	"context"

	"baidu/api/internal/svc"
	"baidu/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type TypesLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TypesLogic {
	return &TypesLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *TypesLogic) Types(req *types.TypesRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	register, err := l.svcCtx.BaiDu.Types(l.ctx, &baidurpc.TypesRequest{
		Type:   req.Type,
		TextId: req.TextId,
	})
	if err != nil {
		return &types.Response{
			Message: "分类失败",
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "分类成功",
		Code:    200,
		Data:    register,
	}, nil
}
